vec2 fixuv(in vec2 uv) {
    vec2 p =  (2. * uv - iResolution.xy) / min(iResolution.x, iResolution.y);
    return p;
}

vec3 drawGrid(in vec2 p) {
    vec3 col = vec3(0.5);
    vec2 fraction = 1. - 2. * abs(fract(p) - .5);
    vec2 mxy = abs(p - fract(p));
    float su = mxy.x + mxy.y;
    // 绘制黑白网格
    col = mix(col, vec3(0.8), smoothstep(0., 1., mod(su, 2.)));
    // 画中垂线
    col = mix(col, vec3(1., 0., 0.), smoothstep(abs(p.x) * 0.95, abs(p.x), fwidth(p.x) * 1.));
    col = mix(col, vec3(0., 1., 0.), smoothstep(abs(p.y) * 0.95, abs(p.y), fwidth(p.x) * 1.));
    return col;
}

vec3 func(in vec2 p,in float t){

    vec3 col ;


    float r = 1000.*cos(t+p.x*sin(p.x));
    float g = cos(t+p.y*p.y*p.x);
    float b = cos(t+r*g);
    col = vec3(r,g,b);

    return col ;

}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 p = fixuv(fragCoord);
    vec3 col = vec3(0.);
    col = drawGrid(p);
    
    fragColor = vec4(col, 1.);
}
